package fr.uniscol.view.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import fr.uniscol.model.utilisateur.User;

public class UtilisateurFormValidator implements Validator {

	public boolean supports(Class<?> clazz) {
		return User.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nom", "errors.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prenom", "errors.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "login", "errors.required");
	}
}
